#pragma once

#define TOUCH_PORT_POWER            GPIO_P1
#define TOUCH_PIN_POWER             GPIO_Pin_5
#define TOUCH_PORT_MODE             GPIO_P1
#define TOUCH_PIN_MODE              GPIO_Pin_3    
#define TOUCH_PORT_SPEED            GPIO_P1
#define TOUCH_PIN_SPEED             GPIO_Pin_3
#define TOUCH_PORT_UP               GPIO_P1
#define TOUCH_PIN_UP                GPIO_Pin_2
#define TOUCH_PORT_DOWN             GPIO_P1
#define TOUCH_PIN_DOWN              GPIO_Pin_1
#define TOUCH_PORT_PAGE             GPIO_P1
#define TOUCH_PIN_PAGE              GPIO_Pin_0

#define IS_TOUCHED_POWER()          (P15 == 0)
#define IS_TOUCHED_MODE()           (P14 == 0)
#define IS_TOUCHED_SPEED()          (P13 == 0)
#define IS_TOUCHED_UP()             (P11 == 0)
#define IS_TOUCHED_DOWN()           (P12 == 0)
#define IS_TOUCHED_PAGE()           (P10 == 0)
#define IS_TOUCHED()                (P10 == 0 || P11 == 0 || P12 == 0 || P13 == 0 || P14 == 0 || P15 == 0)

#define BIT_STATE_POWER             0x01
#define BIT_STATE_MODE              0x02
#define BIT_STATE_SPEED             0x04
#define BIT_STATE_UP                0x08
#define BIT_STATE_DOWN              0x10
#define BIT_STATE_PAGE              0x20
 

#define LONG_PRESSED_3S_CNT       30      //30 * 100 = 3s
#define LONG_PRESSED_6S_CNT       60      //30 * 100 = 3s

typedef enum
{
    RELEASED = 0,
    PRESSED,
    LONG_PRESSED_3S,
    LONG_PRESSED_6S,
}BTN_STATUS;

void touch_init(void);
void touch_func(void);

